package com.agents.builder.main.tools;

import cn.hutool.core.date.DateUtil;
import com.agents.builder.common.ai.annotation.Tool;
import com.agents.builder.common.ai.core.AbstractAgent;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import jdk.jfr.Description;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.stereotype.Component;

import java.util.function.Function;

@Tool
@Description("获取当前时间/日期")
public class SystemTools extends AbstractAgent<SystemTools.Request, String> {


    protected SystemTools(ChatModel chatModel) {
        super(chatModel);
    }

    @Override
    public String apply(Request request) {
        return getChatClient()
                .prompt()
                .user(request.query())
                .call()
                .content();
    }

    public record Request(
            @JsonProperty(required = true) @JsonPropertyDescription(value = "用户原始的提问") String query) {
    }


    @Component
    @Description("获取当前时间")
    public static class CpuAnalyzer implements Function<CpuAnalyzer.Request, String> {
        @Override
        public String apply(Request request) {
            return DateUtil.now();
        }

        public record Request() {
        }
    }


}
